//
//  AYSPlayDetailView.m
//  AiYingShiProject
//
//  Created by lanou on 15/10/28.
//  Copyright (c) 2015年 李晓理. All rights reserved.
//

#import "AYSPlayDetailView.h"
#import "UILabel+StringFrame.h"
@implementation AYSPlayDetailView

- (instancetype)init
{
    self = [super init];
    if (self)
    {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)];
        label.text =  @"导演：" ;
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:14];
        [self addSubview:label];
        
        _directorLabel = [[UILabel alloc] initWithFrame:CGRectMake(52, 10, SCREEN_WIDTH - 52, 20)];
        _directorLabel.font = [UIFont systemFontOfSize:14];
        _directorLabel.textColor = [UIColor colorWithRed:0.167 green:0.475 blue:0.884 alpha:1.000];
        [self addSubview:_directorLabel];
        
        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, 50, 20)];
        label1.text = @"演员：";
        label1.textColor = [UIColor whiteColor];
        label1.font = [UIFont systemFontOfSize:14];
        [self addSubview:label1];
        
        _actorLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 40, SCREEN_WIDTH - 45, 20)];
       _actorLabel.textColor = [UIColor colorWithRed:0.167 green:0.475 blue:0.884 alpha:1.000];
        _actorLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:_actorLabel];
        
//        UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 50, 20)];
//        label2.text = @"年份：";
//        label2.textColor = [UIColor whiteColor];
//        label2.font = [UIFont systemFontOfSize:14];
//        [self addSubview:label2];
        
        _yearLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 70, SCREEN_WIDTH - 45, 20)];
        _yearLabel.font = [UIFont systemFontOfSize:14];
        _yearLabel.textColor = [UIColor whiteColor];
        [self addSubview:_yearLabel];
        
//        UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 105, 20)];
//        label3.text = @"制作国家/地区：";
//        label3.textColor = [UIColor whiteColor];
//        label3.font = [UIFont systemFontOfSize:14];
//        [self addSubview:label3];
        
        _areaLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 100, SCREEN_WIDTH - 115, 20)];
        _areaLabel.font = [UIFont systemFontOfSize:14];
        _areaLabel.textColor = [UIColor whiteColor];
        [self addSubview:_areaLabel];
        
        _episodeLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 130, SCREEN_WIDTH - 45, 20)];
        _episodeLabel.backgroundColor =[UIColor grayColor];
        _episodeLabel.font = [UIFont systemFontOfSize:14];
        //[self addSubview:_episodeLabel];
        
        //_descLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 160, SCREEN_WIDTH - 10, 200)];
        _descLabel = [[UILabel alloc] init];
        _descLabel.font = [UIFont systemFontOfSize:14];
        _descLabel.numberOfLines = 0;
        _descLabel.textColor = [UIColor whiteColor];
        [self addSubview:_descLabel];
        
    }
    return self;
}

-(void)setDataModel:(AYSPlayDataModel *)dataModel
{
    _dataModel = dataModel;
    _directorLabel.text = dataModel.director;
    _actorLabel.text = dataModel.craw;
    CGSize size1 = [_actorLabel boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 52, 0)];
    _actorLabel.frame = CGRectMake(52, 40, size1.width, size1.height);
    _actorLabel.numberOfLines = 0;
    
    _yearLabel.text = [NSString stringWithFormat:@"年份：%@",dataModel.year];
    _yearLabel.frame = CGRectMake(10, size1.height + 55, SCREEN_WIDTH - 10, 20);
    
    _areaLabel.text = [NSString stringWithFormat:@"制作国家/地区：%@",dataModel.area];
    _areaLabel.frame = CGRectMake(10, size1.height + 85, SCREEN_WIDTH - 10, 20);
    _descLabel.text = dataModel.programedesc;
    CGSize  size = [_descLabel boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 15, 0)];
//    if (dataModel.episode.length != 0)
//    {
//        _descLabel.frame = CGRectMake(10, 130, size.width, size.height);
//    }
//    else
//    {
        _descLabel.frame = CGRectMake(10, 160, size.width, size.height);
//    }
}

- (CGFloat)heightOfDetailView:(UILabel *)label
{
    CGSize size = [label boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 10, 0)];
//    if (_dataModel.episode.length != 0)
//    {
//        return 130 + size.height;
//
//    }
//    else
//    {
        return 160 + size.height;
//    }
}











@end
